package com.ruoyi.web.controller.gym;

import com.ny.domain.ComplaintDO;
import com.ny.dto.ComplaintDTO;
import com.ny.dto.CreateGroup;
import com.ny.dto.DeleteGroup;
import com.ny.dto.RestResult;
import com.ny.dto.UpdateGroup;
import com.ny.query.QueryGroup;
import com.ny.service.ComplaintService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.lang.Boolean;
import java.lang.Integer;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 投诉信息管理
 *
 * @author MSI-NB
 * @date 2025-03-08 13:14:38
 */
@Api("投诉信息管理")
@RequestMapping("complaint")
@RestController
public class ComplaintController {

    @Autowired
    private ComplaintService complaintService;

    /**
     * 新增投诉信息
     *
     * @param complaintDTO 投诉信息封装对象
     * @return
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ApiOperation("新增投诉信息")
    @ResponseBody
    public RestResult<Boolean> addComplaint(@RequestBody @Validated(CreateGroup.class) ComplaintDTO complaintDTO) {
        Boolean result = complaintService.addComplaint(complaintDTO);
        return RestResult.success(result);
    }

    /**
     * 删除投诉信息
     *
     * @param complaintDTO 投诉信息封装对象
     * @return
     */
    @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
    @ApiOperation("删除投诉信息")
    @ResponseBody
    public RestResult<Boolean> deleteComplaint(@RequestBody @Validated(DeleteGroup.class) ComplaintDTO complaintDTO) {
        Boolean result = complaintService.deleteComplaint(complaintDTO);
        return RestResult.success(result);
    }

    /**
     * 更新投诉信息状态
     *
     * @param complaintDTO 投诉信息封装对象
     * @return
     */
    @RequestMapping(value = "/update", method = RequestMethod.PUT)
    @ApiOperation("更新投诉信息状态")
    @ResponseBody
    public RestResult<Boolean> updateComplaintStatus(@RequestBody @Validated(UpdateGroup.class) ComplaintDTO complaintDTO) {
        Boolean result = complaintService.updateComplaintStatus(complaintDTO);
        return RestResult.success(result);
    }

    /**
     * 查询投诉信息
     *
     * @param memberId
     * @return
     */
    @RequestMapping(value = "/info", method = RequestMethod.GET)
    @ApiOperation("查询投诉信息")
    public RestResult<ComplaintDO> getComplaintInfo(@Validated(QueryGroup.class) Integer memberId) {
        ComplaintDO result = complaintService.getComplaintInfo(memberId);
        return RestResult.success(result);
    }

    /**
     * 查询所有投诉信息
     *
     * @return
     */
    @RequestMapping(value = "/infos", method = RequestMethod.GET)
    @ApiOperation("查询所有投诉信息")
    public RestResult<List<ComplaintDO>> getAllComplaintInfos() {
        List<ComplaintDO> result = complaintService.getAllComplaintInfos();
        return RestResult.success(result);
    }
}
